package io.yunho.yunho.interview.one.singleton.autocreate;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

/**
 * @author: Jason
 * @date: 2021/3/6 9:58
 * @description:
 */

@RunWith(SpringRunner.class)
@SpringBootTest
public class SingletonTest {
    @Resource
    private SingletonStaticInit singletonStaticInit ;
    @Test
    public void Test1(){
        System.out.println(singletonStaticInit);
        for(int i=0;i<50;i++){
            new Thread(()->{
                System.out.println(singletonStaticInit);
            },String.valueOf(i)).start();
        }
    }

    public static void main(String[] args) {
//        SingletonOne singletonOne = SingletonOne.INSTANCE;
//        System.out.println(singletonOne);
//        for(int i=0;i<50;i++){
//            new Thread(()->{
//                SingletonOne singletonOne = SingletonOne.INSTANCE;
//                System.out.println(singletonOne);
//            },String.valueOf(i)).start();
//        }
//        SingletonEnum singletonEnum = SingletonEnum.INSTANCE;
//        System.out.println(singletonEnum);
//                for(int i=0;i<50;i++){
//            new Thread(()->{
//                SingletonEnum singletonEnum = SingletonEnum.INSTANCE;
//                System.out.println(singletonEnum);
//            },String.valueOf(i)).start();
//        }
//        SingletonStatic singletonStatic = SingletonStatic.INSTANCE;
//        System.out.println(singletonStatic);
//        for(int i=0;i<50;i++){
//            new Thread(()->{
//                SingletonStatic singletonStatic2 = SingletonStatic.INSTANCE;
//                System.out.println(singletonStatic2);
//            },String.valueOf(i)).start();
//        }

    }
}
